<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Download demo</title>
</head>
<body>

<input type="button" value="download" onclick="download()" />

<script>
    function download() {
        var data = {
            username:"ljw",
            password:"123456"
        };
        var url = "/download3";
        console.log("downloadReq data:",data);
        console.log("downloadReq url:",url);

        var formD = document.createElement("form");
        formD.name = "dldForm";
        formD.action = url;

       for(var key in data){
           console.log("key:",key," value:",data[key]);
           var inputD = document.createElement("input");
           inputD.setAttribute("type","hidden");
           inputD.setAttribute("name",key);
           inputD.setAttribute("value",data[key]);
           formD.appendChild(inputD);
       }
        document.body.appendChild(formD);

        document.getElementsByName("dldForm")[0].submit();
        document.body.removeChild(formD);


    }
</script>
</body>
</html>